﻿//作者：MrLee
//时间：2011-8-23
//名称：日志管理
Ext.namespace('FantastPlatform', 'FantastPlatform.UI');

var openStore = new Ext.data.Store({
    proxy: new Ext.data.HttpProxy({
        url: '../Service/WorkLog.aspx?Action=GetPrompt'
    }),
    reader: new Ext.data.JsonReader({
        root: 'topics',
        totalProperty: 'totalCount',
        id: 'Name',
        fields: ['Name', 'Value']
    }),
    remoteStore: true
});
openStore.load();

FantastPlatform.UI.WorkLogForm = function (config) {
    Ext.apply(this, config);
    var openComboBox = new Ext.form.ComboBox({
        fieldLabel: '<font color="red">*</font>&nbsp;&nbsp;是否设置提示',
        name: 'IsPrompt',
        hiddenName: 'IsPrompt',
        store: openStore,
        displayField: 'Name',
        mode: 'remote',
        valueField: 'Value',
        allowBlank: false,
        editable: false,
        triggerAction: 'all',
        emptyText: '是否设置提示',
        readOnly: true,
        width: 105
    });
    this.items = [{
        layout: 'column',
        border: false,
        labelSeparator: '：',
        items: [
         {
             columnWidth: 1,
             border: false,
             layout: 'form',
             items: [new Ext.form.TextArea({
                 fieldLabel: '日志内容',
                 name: 'Content',
                 allowBlank: false,
                 blankText: " 日志内容不能为空",
                 anchor: '98%'
             })]
         }
//         , {
//             columnWidth: 1,
//             border: false,
//             layout: 'form',
//             items: [new Ext.form.TextField({
//                 fieldLabel: '日志标题',
//                 name: 'Title',
//                 anchor: '98%'
//             })]
//         }
         , {
             columnWidth: .5,
             border: false,
             layout: 'form',
             items: [openComboBox]
         }, {
             columnWidth: .5,
             border: false,
             layout: 'form',
             items: [new FantastPlatform.UI.DateField({
                 fieldLabel: '提示日期',
                 name: 'PromptTime',
                 format: 'Y-m-d',
                 width: 105,
                 dateFormat: 'Y-m-d'
             })]
         }]
    }];

    FantastPlatform.UI.WorkLogForm.superclass.constructor.call(this, {
        bodyStyle: 'padding:5px',
        collapsible: true,
        labelAlign: 'right',
        autoScroll: true,
        border: false
    });
};

Ext.extend(FantastPlatform.UI.WorkLogForm, Ext.form.FormPanel, {
    onRender: function (ct, position) {
        FantastPlatform.UI.WorkLogForm.superclass.onRender.call(this, ct, position);
        if (this.workLogId && this.workLogId != 0) {
            this.add(new Ext.form.Hidden({ name: 'Id', value: this.workLogId }));
            var workLogform = this.form
            var workLogId = this.workLogId
            openStore.reload({ callback: function (form, action) {
                workLogform.load({
                    url: '../Service/WorkLog.aspx?Action=Get',
                    params: { id: workLogId },
                    waitMsg: '正在读取数据...',
                    waitTitle: '请稍后...',
                    failure: function (form, action) {
                        if (action.failureType != 'client') {
                            showErrorMessage('操作失败', action.result.message, '');
                        }
                    }
                });
            }
            });

        }
    }
});
